function [panelRC,panelTE, panelPI]=make_table_panel_output(Output)



BiasRC = mean(Output.RegCoef.b-Output.RegCoef.true);
StdDevRC = std(Output.RegCoef.b-Output.RegCoef.true);
RMSERC = (BiasRC.^2 + StdDevRC.^2).^.5;
CoverageRC = mean(abs(abs(Output.RegCoef.b-Output.RegCoef.true)<1.96*Output.RegCoef.se));
IntLengthRC = mean(Output.RegCoef.se*1.96*2);
FSIntLengthRC = mean(Output.RegCoef.length);
FSCoverRC = mean(Output.RegCoef.cover);


if Output.DGP.p == 200
panelRC = {
['\cline{2-9}     & \multicolumn{8}{c}{A. RegCoef',' }\\ \cline{2-9} '	]															
['Bias	&	',         num2strD(BiasRC(2)),'		&	',         num2strD(BiasRC(1)),'	&	',         num2strD(BiasRC(3)),'	&	',         num2strD(BiasRC(4)),'	&	',         num2strD(BiasRC(5)),'	&	',         num2strD(BiasRC(6)),'	&	',         ' '                  ,'	&	',     ' '                  ,'	\\']
['Std. Dev.	&	',     num2strD(StdDevRC(2)),'		&	',         num2strD(StdDevRC(1)),'	&	',         num2strD(StdDevRC(3)),'	&	',         num2strD(StdDevRC(4)),'	&	',         num2strD(StdDevRC(5)),'	&	',         num2strD(StdDevRC(6)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['RMSE	&	',         num2strD(RMSERC(2)),'		&	',         num2strD(RMSERC(1)),'	&	',         num2strD(RMSERC(3)),'	&	',         num2strD(RMSERC(4)),'	&	',         num2strD(RMSERC(5)),'	&	',         num2strD(RMSERC(6)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Coverage	&	',     num2strD(CoverageRC(2)),'		&	',     num2strD(CoverageRC(1)),'	&	',     num2strD(CoverageRC(3)),'	&	',     num2strD(CoverageRC(4)),'	&	',     num2strD(CoverageRC(5)),'	&	',         num2strD(CoverageRC(6)),'	&	',      num2strD(FSCoverRC(1)),'	&	',     num2strD(FSCoverRC(20)),'	\\']
['Int. Length	&	', num2strD(IntLengthRC(2)),'		&	',     num2strD(IntLengthRC(1)),'	&	',     num2strD(IntLengthRC(3)),'	&	',     num2strD(IntLengthRC(4)),'	&	',     num2strD(IntLengthRC(5)),'	&	',          num2strD(IntLengthRC(6)),'	&	',     num2strD(FSIntLengthRC(1)),'	&	', num2strD(FSIntLengthRC(20)),'	\\']
};
else
 panelRC = {
['\cline{2-9}     & \multicolumn{8}{c}{A. RegCoef',' }\\ \cline{2-9} '	]															
['Bias	&	',         num2strD(BiasRC(2)),'		&	',        ' ','	&	',         num2strD(BiasRC(3)),'	&	',         num2strD(BiasRC(4)),'	&	',         num2strD(BiasRC(5)),'	&	',         num2strD(BiasRC(6)),'	&	',         ' '                  ,'	&	',     ' '                  ,'	\\']
['Std. Dev.	&	',     num2strD(StdDevRC(2)),'		&	',        ' ','	&	',         num2strD(StdDevRC(3)),'	&	',         num2strD(StdDevRC(4)),'	&	',         num2strD(StdDevRC(5)),'	&	',         num2strD(StdDevRC(6)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['RMSE	&	',         num2strD(RMSERC(2)),'		&	',        ' ','	&	',         num2strD(RMSERC(3)),'	&	',         num2strD(RMSERC(4)),'	&	',         num2strD(RMSERC(5)),'	&	',         num2strD(RMSERC(6)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Coverage	&	',     num2strD(CoverageRC(2)),'		&	',    ' ','	&	',     num2strD(CoverageRC(3)),'	&	',     num2strD(CoverageRC(4)),'	&	',     num2strD(CoverageRC(5)),'	&	',         num2strD(CoverageRC(6)),'	&	',      num2strD(FSCoverRC(1)),'	&	',     num2strD(FSCoverRC(20)),'	\\']
['Int. Length	&	', num2strD(IntLengthRC(2)),'		&	',    ' ','	&	',     num2strD(IntLengthRC(3)),'	&	',     num2strD(IntLengthRC(4)),'	&	',     num2strD(IntLengthRC(5)),'	&	',          num2strD(IntLengthRC(6)),'	&	',     num2strD(FSIntLengthRC(1)),'	&	', num2strD(FSIntLengthRC(20)),'	\\']
};   
end

BiasTE = mean(Output.TE.te-Output.TE.true);
StdDevTE = std(Output.TE.te-Output.TE.true);
RMSETE = (BiasTE.^2 + StdDevTE.^2).^.5;
CoverageTE = mean(abs(Output.TE.te-Output.TE.true)<1.96*Output.TE.se);
IntLengthTE = mean(Output.TE.se*1.96*2);
FSIntLengthTE = mean(Output.TE.length);
FSCoverTE = mean(Output.TE.cover);

if Output.DGP.p == 200
panelTE = {
['\cline{2-9}     & \multicolumn{8}{c}{B. TE ', '}\\ \cline{2-9} '	]															
['Bias	&	',         num2strD(BiasTE(2)),'		&	',         num2strD(BiasTE(1)),'	&	',         ' ','	&	',         num2strD(BiasTE(3)),'	&	',         num2strD(BiasTE(4)),'	&	',        num2strD(BiasTE(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Std. Dev.	&	',     num2strD(StdDevTE(2)),'		&	',         num2strD(StdDevTE(1)),'	&	',         ' ','	&	',         num2strD(StdDevTE(3)),'	&	',         num2strD(StdDevTE(4)),'	&	',        num2strD(StdDevTE(5)),'	&	',      ' '                  ,'	&	',     ' '                  ,'	\\']
['RMSE	&	',         num2strD(RMSETE(2)),'		&	',         num2strD(RMSETE(1)),'	&	',         ' ','	&	',         num2strD(RMSETE(3)),'	&	',         num2strD(RMSETE(4)),'	&	',        num2strD(RMSETE(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Coverage	&	',     num2strD(CoverageTE(2)),'		&	',     num2strD(CoverageTE(1)),'	&	',     ' ','	&	',         num2strD(CoverageTE(3)),'	&	',     num2strD(CoverageTE(4)),'	&	',        num2strD(CoverageTE(5)),'	&	',      num2strD(FSCoverTE(1)),'	&	',     num2strD(FSCoverTE(20)),'	\\']
['Int. Length	&	', num2strD(IntLengthTE(2)),'		&	',     num2strD(IntLengthTE(1)),'	&	',     ' ','	&	',         num2strD(IntLengthTE(3)),'	&	',     num2strD(IntLengthTE(4)),'	&	',        num2strD(IntLengthTE(5)),'	&	',      num2strD(FSIntLengthTE(1)),'	&	', num2strD(FSIntLengthTE(20)),'	\\']
};
else
panelTE = {
['\cline{2-9}     & \multicolumn{8}{c}{B. TE ', '}\\ \cline{2-9} '	]															
['Bias	&	',         num2strD(BiasTE(2)),'		&	',         ' ','	&	',         ' ','	&	',         num2strD(BiasTE(3)),'	&	',         num2strD(BiasTE(4)),'	&	',        num2strD(BiasTE(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Std. Dev.	&	',     num2strD(StdDevTE(2)),'		&	',         ' ','	&	',         ' ','	&	',         num2strD(StdDevTE(3)),'	&	',         num2strD(StdDevTE(4)),'	&	',        num2strD(StdDevTE(5)),'	&	',      ' '                  ,'	&	',     ' '                  ,'	\\']
['RMSE	&	',         num2strD(RMSETE(2)),'		&	',         ' ','	&	',         ' ','	&	',         num2strD(RMSETE(3)),'	&	',         num2strD(RMSETE(4)),'	&	',        num2strD(RMSETE(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Coverage	&	',     num2strD(CoverageTE(2)),'		&	',     ' ','	&	',     ' ','	&	',         num2strD(CoverageTE(3)),'	&	',     num2strD(CoverageTE(4)),'	&	',        num2strD(CoverageTE(5)),'	&	',      num2strD(FSCoverTE(1)),'	&	',     num2strD(FSCoverTE(20)),'	\\']
['Int. Length	&	', num2strD(IntLengthTE(2)),'		&	',     ' ','	&	',     ' ','	&	',         num2strD(IntLengthTE(3)),'	&	',     num2strD(IntLengthTE(4)),'	&	',        num2strD(IntLengthTE(5)),'	&	',      num2strD(FSIntLengthTE(1)),'	&	', num2strD(FSIntLengthTE(20)),'	\\']
};   
    
end

BiasPI = mean(Output.PI.te-Output.PI.true);
StdDevPI = std(Output.PI.te-Output.PI.true);
RMSEPI = (BiasTE.^2 + StdDevTE.^2).^.5;
CoveragePI = mean(abs(Output.PI.te-Output.PI.true)<1.96*Output.PI.se);
IntLengthPI = mean(Output.PI.se*1.96*2);
FSIntLengthPI = mean(Output.PI.length);
FSCoverPI = mean(Output.PI.cover);

if Output.DGP.p == 200
panelPI = {
['\cline{2-9}     & \multicolumn{8}{c}{C. PI' , ' }\\ \cline{2-9} '	]															
['Bias	&	',         num2strD(BiasPI(2)),'		&	',         num2strD(BiasPI(1)),'	&	',         ' ','	&	',         num2strD(BiasPI(3)),'	&	',         num2strD(BiasPI(4)),'	&	',         num2strD(BiasPI(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Std. Dev.	&	',     num2strD(StdDevPI(2)),'		&	',         num2strD(StdDevPI(1)),'	&	',         ' ','	&	',         num2strD(StdDevPI(3)),'	&	',         num2strD(StdDevPI(4)),'	&	',         num2strD(StdDevPI(5)),'	&	',      ' '                  ,'	&	',     ' '                  ,'	\\']
['RMSE	&	',         num2strD(RMSEPI(2)),'		&	',         num2strD(RMSEPI(1)),'	&	',         ' ','	&	',         num2strD(RMSEPI(3)),'	&	',         num2strD(RMSEPI(4)),'	&	',         num2strD(RMSEPI(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Coverage	&	',     num2strD(CoveragePI(2)),'		&	',     num2strD(CoveragePI(1)),'	&	',     ' ','	&	',         num2strD(CoveragePI(3)),'	&	',     num2strD(CoveragePI(4)),'	&	',         num2strD(CoveragePI(5)),'	&	',      num2strD(FSCoverPI(1)),'	&	',     num2strD(FSCoverPI(10)),'	\\']
['Int. Length	&	', num2strD(IntLengthPI(2)),'		&	',     num2strD(IntLengthPI(1)),'	&	',     ' ','	&	',         num2strD(IntLengthPI(3)),'	&	',     num2strD(IntLengthPI(4)),'	&	',         num2strD(IntLengthPI(5)),'	&	',      num2strD(FSIntLengthPI(1)),'	&	', num2strD(FSIntLengthPI(10)),'	\\']
};

else
 panelPI = {
['\cline{2-9}     & \multicolumn{8}{c}{C. PI' , ' }\\ \cline{2-9} '	]															
['Bias	&	',         num2strD(BiasPI(2)),'		&	',        ' ' ,'	&	',         ' ','	&	',         num2strD(BiasPI(3)),'	&	',         num2strD(BiasPI(4)),'	&	',         num2strD(BiasPI(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Std. Dev.	&	',     num2strD(StdDevPI(2)),'		&	',          ' ' ,'	&	',         ' ','	&	',         num2strD(StdDevPI(3)),'	&	',         num2strD(StdDevPI(4)),'	&	',         num2strD(StdDevPI(5)),'	&	',      ' '                  ,'	&	',     ' '                  ,'	\\']
['RMSE	&	',         num2strD(RMSEPI(2)),'		&	',         ' ' ,'	&	',         ' ','	&	',         num2strD(RMSEPI(3)),'	&	',         num2strD(RMSEPI(4)),'	&	',         num2strD(RMSEPI(5)),'	&	',          ' '                  ,'	&	',     ' '                  ,'	\\']
['Coverage	&	',     num2strD(CoveragePI(2)),'		&	',     ' ' ,'	&	',     ' ','	&	',         num2strD(CoveragePI(3)),'	&	',     num2strD(CoveragePI(4)),'	&	',         num2strD(CoveragePI(5)),'	&	',      num2strD(FSCoverPI(1)),'	&	',     num2strD(FSCoverPI(10)),'	\\']
['Int. Length	&	', num2strD(IntLengthPI(2)),'		&	',     ' ' ,'	&	',     ' ','	&	',         num2strD(IntLengthPI(3)),'	&	',     num2strD(IntLengthPI(4)),'	&	',         num2strD(IntLengthPI(5)),'	&	',      num2strD(FSIntLengthPI(1)),'	&	', num2strD(FSIntLengthPI(10)),'	\\']
};   
end
    


figure(1)
set(gcf,'Position',[230,250,1450,850]) 
subplot(2,17,1:4)
plot(0:10,[CoverageRC(5),mean(Output.RegCoef.cover(:,1:10))],'k-','linewidth',2), hold on, plot( 0:10, ones(11,1)*CoverageRC(2),'k--','linewidth',2), hold off
%legend('FS','True','All','PostDouble','location','northwestoutside')
title('RegCoef Coverage','fontsize',20)
ylim([0.5,1])
set(gca,'ytick',.5:.1:1,'YTickLabel',{'<0.5',0.6,.7,.8,.9,1}, 'fontsize',16)
set(gca,'xtick',0:2:10)


subplot(2,17,18:21)
plot(0:10,[IntLengthRC(5),mean(Output.RegCoef.length(:,1:10))],'k-','linewidth',2), hold on, plot( 0:10, ones(11,1)*IntLengthRC(2),'k--','linewidth',2), hold off
%legend('FS','True','All','PostDouble')
title('RegCoef Interval Length','fontsize',20)
ylim([0,5])
set(gca,'ytick',0:1:5, 'fontsize',16)
set(gca,'xtick',0:2:10)
%

subplot(2,17,6:9)
plot(0:10,[CoverageTE(4),mean(Output.TE.cover(:,1:10))],'k-','linewidth',2), hold on, plot( 0:10, ones(11,1)*CoverageTE(2),'k--','linewidth',2), hold off
%legend('FS','True','All')
title('TE Coverage','fontsize',20)
ylim([0.5,1])
set(gca,'ytick',.5:.1:1,'YTickLabel',{'<0.5',0.6,.7,.8,.9,1}, 'fontsize',16)
set(gca,'xtick',0:2:10)


subplot(2,17,23:26)
plot(0:10,[IntLengthTE(4),mean(Output.TE.length(:,1:10))],'k-','linewidth',2), hold on, plot( 0:10, ones(11,1)*IntLengthTE(2),'k--','linewidth',2), hold off
%legend('FS','True','All')
title('TE Interval Length','fontsize',20)
ylim([0,20])
set(gca,'ytick',0:4:20, 'fontsize',16)
set(gca,'xtick',0:2:10)


subplot(2,17,11:14)
plot(0:10,[CoveragePI(4),mean(Output.PI.cover(:,1:10))],'k-','linewidth',2), hold on, plot( 0:10, ones(11,1)*CoveragePI(2),'k--','linewidth',2), hold off
%legend('FS     ','True    ','Position',[1200 660 10 10]','fontsize',20)
%legend('FS     ','True    ','Position',[1200 660 100 100]','fontsize',20)
legend1 = legend('FS','True');
set(legend1,...
    'Position',[0.795 0.820 0.120 0.082]);

title('PI Coverage','fontsize',20)
ylim([0.5,1])
set(gca,'ytick',.5:.1:1,'YTickLabel',{'<0.5',0.6,.7,.8,.9,1}, 'fontsize',16)
set(gca,'xtick',0:2:10)



subplot(2,17,28:31)
plot(0:10,[IntLengthPI(4),mean(Output.PI.length(:,1:10))],'k-','linewidth',2), hold on, plot( 0:10, ones(11,1)*IntLengthPI(2),'k--','linewidth',2), hold off
%legend('FS','True','All')
title('PI Interval Length','fontsize',20)
ylim([0,1])
set(gca,'ytick',0:.2:1, 'fontsize',16)
set(gca,'xtick',0:2:10)



function X=num2strD(Y)
X=num2str(Y,'%1.2f \t');

